//
//  YYDiscoverTableViewController.swift
//  YYWeibo
//
//  Created by strongwallyi on 15/12/26.
//  Copyright © 2015年 strongwallyi. All rights reserved.
//

import UIKit

class YYDiscoverTableViewController: YYVisitorTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //如果没有登陆的话,那么就不显示搜索框,直接进行 return
        if userLogin == false{
            visitorView.setupInfo("visitordiscover_image_message", messageText: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            return
        }

        let searchView = YYDiscoverSearchView.search()
        
        searchView.frame.size.width = SCREENW
        
        navigationItem.titleView = searchView
        
        tabBarItem.badgeValue = "10"
    }
    
    //寻找系统控件的私有属性,且更改其值
    private func demo(){
        //遍历控件
        let tabBar = self.tabBarController!.tabBar

        for tabBarChild in tabBar.subviews {
            if tabBarChild.isKindOfClass(NSClassFromString("UITabBarButton")!){
                //继续遍历
                for tabBarButtonChild in tabBarChild.subviews{
                    if tabBarButtonChild.isKindOfClass(NSClassFromString("_UIBadgeView")!) {
                        // 继承遍历
                        for badgeViewChild in tabBarButtonChild.subviews {
                            if badgeViewChild.isKindOfClass(NSClassFromString("_UIBadgeBackground")!) {
                                badgeViewChild.setValue(UIImage(named: "main_badge"), forKeyPath: "_image")
                            }
                        }
                    }
                }
            }
        }
    }
}
